# 导包
from api.order import OrderAPI
# 创建测试类
class TestOrderAPI:
    #初始化
    order_id = None
    #前置处理
    def setup(self):
        self.order_api = OrderAPI()

    # 获取订单列表
    def test01_get_order_list(self):
        response = self.order_api.get_order_list()
        print(response.json())
    # 创建订单成功
    def test02_add_order(self):
        add_data = {"products": [{"product_id": 8, "count": 1}, {"product_id": 10, "count": 2}]}
        response = self.order_api.add_order(add_data)
        print(response.json())
        # 提取订单编号并保存到类的属性
        TestOrderAPI.order_id = response.json().get("order_id")
        print(TestOrderAPI.order_id)
    # 查看订单
    def test03_get_order_info(self):
        response = self.order_api.get_order_info(TestOrderAPI.order_id)
        print(response.url)
        print(response.json())




